/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bookshop.dao;

import com.bookshop.entity.Customerorder;
import java.io.Serializable;
import java.util.List;
import javax.ejb.Singleton;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Samir
 */
@Singleton(mappedName = "com.bookshop.service.Customerorder")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class DaoCustomerOrderImpl implements IDaoCustomerOrderLocal,IDaoCustomerOrderRemote, Serializable {

    @PersistenceContext
    private EntityManager em;
    private List<Customerorder> customerOrderList;

    @Override
    public double getTotal() {
        double retour = 0d;
        customerOrderList = em.createNamedQuery("Customerorder.findByCustomerId").setParameter("customerid", 1).setParameter("confirmationNumber", 0).getResultList();
        for (Customerorder co : customerOrderList) {
                retour = co.getAmount();
        }
        return retour;
    }
    
  // DecimalFormat df = new DecimalFormat("#,###.00");
    
}
